<template>
	<view>
        <!--<view class="eva-header">-->
            <!--<view class="h-type" :class="tabIndex==0?'active':''" @click="showAppraise('0')">全部</view>-->
            <!--<view class="h-type" :class="tabIndex==1?'active':''" @click="showAppraise('1')">待付款</view>-->
            <!--<view class="h-type" :class="tabIndex==2?'active':''" @click="showAppraise('2')">待收货</view>-->
            <!--<view class="h-type" :class="tabIndex==3?'active':''" @click="showAppraise('3')">待评价</view>-->
        <!--</view>-->
		<view class="goods-section" v-for="(item,index) in orderList" :key="index" @click="navToDetailPage(item.id,item,item.status,item.confirmStatus)">
			<view class="g-header b-b">
				<text class="name">{{item.wareHouseName}}</text>
                <text class="g-status" v-if="item.status==0">待付款</text>
                <!--<text class="g-status" v-if="item.status==3&&item.confirmStatus==0">待收货</text>-->
                <!--<text class="g-status" v-if="item.status==3&&item.confirmStatus==1">待评价</text>-->
			</view>
			<!-- 商品列表 -->
			<view class="g-item" v-for="(childItem,childIndx) in item.orderItemList" :key="childIndx">
				<image :src="childItem.productPic"></image>
				<view class="right">
					<view class="title clamp"><view class="t-name">{{childItem.productName}}  </view><text class="price">￥{{childItem.productPrice}}</text></view>
					<view class="price-box">
                        <view style="display: flex;align-items: center"><img :src="childItem.nationalFlag" alt="">{{childItem.originCountry}}</view>
						<text class="number">x {{childItem.productQuantity}}</text>
					</view>
                    <text class="spec">规格：{{childItem.productAttr}}</text>
				</view>
				<view class="g-count">
					<view style="flex:1">
						<text class="num">{{childItem.refundType == '1' ? '退款' : '退货退款'}}</text>
						<text></text>
						<text class="num">
							{{childItem.refundStatus == '0' ? '未退款' : childItem.refundStatus == '1' ? '退款中' : '退款成功'}}
						</text>
					</view>

					<view class="g-btn">
						<view class="g-cancel"
							  @click.stop="goRefundDetail(item.id,childItem.productId,childItem.productSkuId,childItem.refundStatus,item)">
							服务详情
						</view>
						<!--<view class="g-pay" @click.stop="appraisePro(item.id)">评价</view>-->
					</view>
				</view>
			</view>
			<view class="g-count" v-for="(childItem,childIndx) in item.orderItemList" :key="childIndx">

			</view>

		</view>
	</view>
</template>

<script>
    import {_orderList} from '../../common/vmeitime-http/order.js'
	export default {
		data() {
			return {
                tabIndex:4,
				desc: '', //备注
				orderList:[]
			}
		},
		onLoad(options){
			//订单列表
			//let data = JSON.parse(option.data);
			//console.log(data);

			if(options.state){
                this.tabIndex = options.state;
			}
			this.gotList(this.tabIndex)
		},
		methods: {
			//显示优惠券面板
			submit(){
				uni.redirectTo({
					url: '/pages/money/pay'
				})
			},
			stopPrevent(){},
			/*切换选项卡*/
            showAppraise(n){
                this.tabIndex = n;
                this.gotList(n)
            },
			async gotList(status){
                let para = {
                    pageNum:"1",
					pageSize:"20",
					status:status
				};
                let tempStatus = await _orderList(para);
                this.orderList = tempStatus.data.data;
                console.log(tempStatus)
            },
//			/*查看物流*/
//            showLog(orderId,count,pic){
//                uni.navigateTo({
//                    url: `/pages/logistics/logistics?orderId=${orderId}&count=${count}&pic=${pic}`
//                })
//			},
            //详情
            // <text class="g-status" v-if="item.status==3&&item.confirmStatus==0">待收货</text>
        // <text class="g-status" v-if="item.status==3&&item.confirmStatus==1">待评价</text>
            navToDetailPage(orderId,dataS,orderStatus,confirmStatus){
                //测试数据没有写id，用title代替
//				let id = item.title;
				if(orderStatus==0){
				    orderStatus = "detailPay";
				}else if(orderStatus==3&&confirmStatus==0){
                    orderStatus = "pending"
				}else if(orderStatus==3&&confirmStatus==1){
                    orderStatus = "comment"
				}else{
                    orderStatus = "refund"
				}
				dataS = JSON.stringify(dataS);
                uni.navigateTo({
                    url: `/pages/order/orderDetails?orderId=${orderId}`
                })
            },
            /*退款详情*/
            async goRefundDetail(orderId,proId,productSkuId,refundStatus,dataS){
                if(refundStatus==2){
                    dataS = JSON.stringify(dataS);
                    uni.navigateTo({
                        url: `/pages/order/orderDetails?orderId=${orderId}`
                    })
				}else{
                    // uni.navigateTo({
                    //     url: `/pages/refund/refund_detail?orderId=${orderId}&proId=${proId}&productSkuId=${productSkuId}`
                    // })
				}
            },
		}
	}
</script>

<style lang="scss">
	page {
		background: $page-color-base;
		padding-bottom: 100upx;
	}
    /*头部*/
    .eva-header{
        display: flex;
        padding: 26upx 35upx 0;
        justify-content:space-between;
        background: #ffffff;
        .h-type{
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 26upx;
            color: $font-color-dark;
            height: 53upx;
            padding: 0 20upx 20upx 30upx;
            border-bottom: 4upx solid #ffffff;
            /*flex: 1;*/
            &.active{
                border-bottom: 4upx solid $uni-color-primary;
                color: $uni-color-primary;
            }
        }
    }
    /*列表*/
	.goods-section {
		margin-bottom: 20upx;
		background: #fff;
		padding-bottom: 1px;

		.g-header {
			display: flex;
			align-items: center;
			height: 84upx;
			padding: 0 30upx;
			position: relative;
            .g-status{
                color: $uni-color-primary;
                font-size: 30upx;
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: flex-end;
            }
            .name {
                font-size: 30upx;
                color: $font-color-dark;
                /*margin-left: 24upx;*/
                font-weight: bold;
            }
		}
		.g-item {
			display: flex;
			margin: 20upx 30upx;
			flex-wrap: wrap;
			image {
				flex-shrink: 0;
				display: block;
				width: 140upx;
				height: 140upx;
				border-radius: 4upx;
			}

			.right {
				flex: 1;
				padding-left: 24upx;
				overflow: hidden;
			}

			.title {
				font-size: 30upx;
				color: $font-color-dark;
                .t-name{
                    width: 376upx;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }
                .price{
                    font-size: 26upx;
                    color: #656565;
                    float: right;
                    margin-top: -38rpx;
                }
			}

			.spec {
				font-size: 22upx;
				color: $font-color-light;
			}

			.price-box {
				/*display: flex;*/
				align-items: center;
				font-size: 24upx;
				color: #989898;
				padding-top: 10upx;
				.price {
					margin-bottom: 4upx;
				}
				.number{
					font-size: 26upx;
					color: $font-color-base;
					margin-left: 20upx;
                    float: right;
                    margin-top: -34rpx;
                }
                img{
                    width: 23upx;
                    height: 23upx;
                    display: inline-block;
                    margin-right: 20upx;
					border-radius: 50%;
                }
			}

			.step-box {
				position: relative;
			}
		}
		.g-count{
			display: flex;
			font-size: 24upx;
			color: #656565;
			align-items: center;
			/*justify-content: flex-end;*/
            padding: 0 0 0 30upx;
			width: 100%;
            .num{
				margin-right: 10upx;
			}
			.total{
				font-size: 30upx;
				margin-left: 10upx;
			}
		}
        .g-btn{
            font-size: 26upx;
            display: flex;
            justify-content: flex-end;
            padding: 30upx 0;
            .g-cancel{
                padding: 16upx 28upx;
                border-radius: 60upx;
                color: #989898;
                border: 2upx solid #989898;
                /*margin-right: 20upx;*/
            }
            .g-pay{
                padding: 16upx 28upx;
                border-radius: 60upx;
                color: $uni-color-primary;
                border: 2upx solid $uni-color-primary;
            }
        }
	}
	.yt-list {
		margin-top: 16upx;
		background: #fff;
	}

	.yt-list-cell {
		display: flex;
		align-items: center;
		padding: 10upx 30upx 10upx 40upx;
		line-height: 70upx;
		position: relative;

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		.cell-icon {
			height: 32upx;
			width: 32upx;
			font-size: 22upx;
			color: #fff;
			text-align: center;
			line-height: 32upx;
			background: #f85e52;
			border-radius: 4upx;
			margin-right: 12upx;

			&.hb {
				background: #ffaa0e;
			}

			&.lpk {
				background: #3ab54a;
			}

		}

		.cell-more {
			align-self: center;
			font-size: 24upx;
			color: $font-color-light;
			margin-left: 8upx;
			margin-right: -10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 26upx;
			color: $font-color-dark;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 26upx;
			color: $font-color-dark;

			&.disabled {
				color: $font-color-light;
			}

			&.active {
				color: $base-color;
			}
			&.red{
				color: $base-color;
			}
		}

		&.desc-cell {
			.cell-tit {
				max-width: 90upx;
			}
		}

		.desc {
			flex: 1;
			font-size: $font-base;
			color: $font-color-dark;
		}
	}
	
	/* 支付列表 */
	.pay-list{
		padding-left: 40upx;
		margin-top: 16upx;
		background: #fff;
		.pay-item{
			display: flex;
			align-items: center;
			padding-right: 20upx;
			line-height: 1;
			height: 110upx;	
			position: relative;
		}
		.icon-weixinzhifu{
			width: 80upx;
			font-size: 40upx;
			color: #6BCC03;
		}
		.icon-alipay{
			width: 80upx;
			font-size: 40upx;
			color: #06B4FD;
		}
		.icon-xuanzhong2{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 60upx;
			height: 60upx;
			font-size: 40upx;
			color: $base-color;
		}
		.tit{
			font-size: 32upx;
			color: $font-color-dark;
			flex: 1;
		}
	}
	/* 优惠券面板 */
	.mask{
		display: flex;
		align-items: flex-end;
		position: fixed;
		left: 0;
		top: var(--window-top);
		bottom: 0;
		width: 100%;
		background: rgba(0,0,0,0);
		z-index: 9995;
		transition: .3s;
		
		.mask-content{
			width: 100%;
			min-height: 30vh;
			max-height: 70vh;
			background: #f3f3f3;
			transform: translateY(100%);
			transition: .3s;
			overflow-y:scroll;
		}
		&.none{
			display: none;
		}
		&.show{
			background: rgba(0,0,0,.4);
			
			.mask-content{
				transform: translateY(0);
			}
		}
	}

	/* 优惠券列表 */
	.coupon-item{
		display: flex;
		flex-direction: column;
		margin: 20upx 24upx;
		background: #fff;
		.con{
			display: flex;
			align-items: center;
			position: relative;
			height: 120upx;
			padding: 0 30upx;
			&:after{
				position: absolute;
				left: 0;
				bottom: 0;
				content: '';
				width: 100%;
				height: 0;
				border-bottom: 1px dashed #f3f3f3;
				transform: scaleY(50%);
			}
		}
		.left{
			display: flex;
			flex-direction: column;
			justify-content: center;
			flex: 1;
			overflow: hidden;
			height: 100upx;
		}
		.title{
			font-size: 32upx;
			color: $font-color-dark;
			margin-bottom: 10upx;
		}
		.time{
			font-size: 24upx;
			color: $font-color-light;
		}
		.right{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 26upx;
			color: $font-color-base;
			height: 100upx;
		}
		.price{
			font-size: 44upx;
			color: $base-color;
			&:before{
				content: '￥';
				font-size: 34upx;
			}
		}
		.tips{
			font-size: 24upx;
			color: $font-color-light;
			line-height: 60upx;
			padding-left: 30upx;
		}
		.circle{
			position: absolute;
			left: -6upx;
			bottom: -10upx;
			z-index: 10;
			width: 20upx;
			height: 20upx;
			background: #f3f3f3;
			border-radius: 100px;
			&.r{
				left: auto;
				right: -6upx;
			}
		}
	}

</style>
